package com.xuan.webfinally.service.impl;

import com.xuan.webfinally.entity.SlopeDeviceStatus;
import com.xuan.webfinally.mapper.SlopeDeviceInfoMapper;
import com.xuan.webfinally.mapper.SlopeDeviceStatusMapper;
import com.xuan.webfinally.mapper.SysUserMapper;
import com.xuan.webfinally.service.ISlopeDeviceStatusService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gyuxuan
 * @since 2025-05-18
 */
@Service
public class SlopeDeviceStatusServiceImpl extends ServiceImpl<SlopeDeviceStatusMapper, SlopeDeviceStatus> implements ISlopeDeviceStatusService {

    @Autowired
    private SlopeDeviceStatusMapper slopeDeviceStatusMapper;

    @Autowired
    private SysUserMapper  sysUserMapper;

    @Autowired
    private SlopeDeviceInfoMapper slopeDeviceInfoMapper;

    @Override
    public int getYJValue(String username,Long deptId) {
        if (deptId == 100L)
        {
            return slopeDeviceInfoMapper.getWays();
        }
        return slopeDeviceInfoMapper.getWay(deptId);
//        Long DeptId = sysUserMapper.selectDeptId(username);
//        return slopeDeviceInfoMapper.getWay(DeptId);
    }

    @Override
    public int getLXValue(String username,Long deptId) {
        if (username == "admin")
        {
            return slopeDeviceInfoMapper.getLx(deptId);
        }
        Long DeptId = sysUserMapper.selectDeptId(username);

        return slopeDeviceInfoMapper.getLx(DeptId);
    }

    @Override
    public int getZCValue(String username,Long deptId) {
        if (username == "admin")
        {
            return slopeDeviceInfoMapper.getZc(deptId);
        }
        Long DeptId = sysUserMapper.selectDeptId(username);

        return slopeDeviceInfoMapper.getZc(DeptId);
    }
}
